1. Field of the Invention
The present invention is generally directed to a method and system for managing the flow of data within the system. More particularly, the present invention is directed to a method and system for buffering data.
2. Description of the Related Art
Many conventional computers and electronic processing systems require quick access to selected data stored in mass memory. Typically, mass memory devices for storing large quantities of data are organized in sectors. Accessing data from these sectors of memory can be undesirably slow, particularly when the memory device is a disc or CD ROM product, as is often the case.
In order to improve retrieval of data from mass memory storage, input/output systems, and particularly buffering techniques, have been proposed for minimizing repetitive access to the mass data storage unit. Such systems implement a single input/output (I/O) buffer for each file to be opened. Particularly, a processor in such systems determines that data within a particular sector is needed, and will retrieve that data into the I/O buffer. Each time the system desires access to data within a particular file, the processor will determine whether the desired data is already in the I/O buffer. If the desired data is within the I/O buffer, then the data required will be retrieved directly from the I/O buffer. When, however, the required data is not within the I/O buffer, the complete sector of data containing the desired data is retrieved from the mass data storage unit. As will be appreciated, the ability to retrieve required data directly from the buffer, which is typically random access memory (RAM), without having to access the mass data storage unit, greatly speeds processing time. However, in most operations, it will typically be necessary to sequentially or periodically access data from a sector other than the sector stored in the I/O buffer. The need to repeatedly access data from mass memory storage requires repeated flushing of the I/O buffer to make space for new data, which itself must be retrieved, thereby greatly reducing system processing speed.
In an effort to improve data management and processing speed in systems involving mass data storage, systems with a second buffer, known as a cache buffer and software, have been implemented. In such systems, an I/O buffer of an open file communicates with a cache buffer such that, when the processor requires data other than that which is stored in the I/O buffer, processor scans the cache buffer to determine if the desired sector of data is already within the cache buffer. When the desired data is present in the cache buffer, it is handed directly from the buffer to the processor without the need to access the mass data storage unit. When the desired data is not within the cache buffer, the processor retrieves the required sector of data from the mass memory storage device. A certain number of sectors of previously used data are maintained in the cache buffer in an effort to minimize the time spent accessing the mass data storage unit during subsequent processing.
FIG. 1 illustrates a portion of a system utilizing a conventional cache buffer. Once a file, such as File 1 for instance, is opened, the processor determines whether the buffer associated with File 1 (e.g., I/O buffer 1) has data that is desired stored therein. If the data is stored within the file's associated I/O buffer, the desired data can be extracted from the I/O buffer and utilized. When, however, the desired data is not found within the associated I/O buffer of the open file, the processor scans the cache buffer to determine whether the desired data is already within the cache buffer. In practice, each of the I/O buffer and cache buffer have associated software code, I/O code and cache code, respectively. When the desired data is present within the cache buffer, the cache code causes the desired data to be sent to the I/O buffer, where it is in turn handed to the I/O code for use in the process being undertaken. When, however, the desired data is not found by the cache code within its cache buffer, the cache code must extract the desired data from the appropriate sector (S.sub.1, S.sub.2, . . . S.sub.n) and store the sector of data within the cache buffer. The cache code then transmits the data to the I/O buffer, where it is handed to the I/O code for use in the process being conducted. As will be understood, the extracted sector of data is maintained within the cache buffer such that subsequent operations requiring the same data can access the cache buffer, without the necessity to access the mass data storage unit. It should be understood that the I/O buffer is a single storage location, while the cache buffer typically has multiple storage locations for storing multiple sectors of data. The cache buffer will flush a sector of data when it is necessary to retrieve an additional sector of data, but all cache buffer locations are full.
Although caching systems have improved data handling and processing speed, a primary drawback of such systems is the increase in memory space, and particularly RAM memory space which is conventional in use for cache and I/O buffers. The increase in such memory space increases the costs of the system. Thus, systems having the cache buffer and an I/O buffer for each file in memory utilize a great deal of expensive memory, thus increasing the cost of the system or product in which the system is embodied.
Accordingly, the need exists for an inexpensive system which quickly and efficiently handles the transfer or retrieval of data. Particularly, the need exists for a system having the benefits of cache buffering without the necessity for multiple buffers. The present invention fills these and other needs, and overcomes the drawbacks of the prior art.